package com.skt.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.skt.common.annotation.Log;
import com.skt.common.core.controller.BaseController;
import com.skt.common.core.domain.AjaxResult;
import com.skt.common.enums.BusinessType;
import com.skt.manage.domain.HealthResources;
import com.skt.manage.service.IHealthResourcesService;
import com.skt.common.utils.poi.ExcelUtil;
import com.skt.common.core.page.TableDataInfo;

/**
 * 健康资讯资源Controller
 * 
 * @author ffbaby
 * @date 2025-04-14
 */
@RestController
@RequestMapping("/manage/resources")
public class HealthResourcesController extends BaseController
{
    @Autowired
    private IHealthResourcesService healthResourcesService;

    /**
     * 查询健康资讯资源列表
     */
//    @PreAuthorize("@ss.hasPermi('manage:resources:list')")
    @GetMapping("/list")
    public TableDataInfo list(HealthResources healthResources)
    {
        startPage();
        List<HealthResources> list = healthResourcesService.selectHealthResourcesList(healthResources);
        return getDataTable(list);
    }

    /**
     * 导出健康资讯资源列表
     */
    @PreAuthorize("@ss.hasPermi('manage:resources:export')")
    @Log(title = "健康资讯资源", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HealthResources healthResources)
    {
        List<HealthResources> list = healthResourcesService.selectHealthResourcesList(healthResources);
        ExcelUtil<HealthResources> util = new ExcelUtil<HealthResources>(HealthResources.class);
        util.exportExcel(response, list, "健康资讯资源数据");
    }

    /**
     * 获取健康资讯资源详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:resources:query')")
    @GetMapping(value = "/{resourceId}")
    public AjaxResult getInfo(@PathVariable("resourceId") Long resourceId)
    {
        return success(healthResourcesService.selectHealthResourcesByResourceId(resourceId));
    }

    /**
     * 新增健康资讯资源
     */
    @PreAuthorize("@ss.hasPermi('manage:resources:add')")
    @Log(title = "健康资讯资源", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HealthResources healthResources)
    {
        return toAjax(healthResourcesService.insertHealthResources(healthResources));
    }

    /**
     * 修改健康资讯资源
     */
    @PreAuthorize("@ss.hasPermi('manage:resources:edit')")
    @Log(title = "健康资讯资源", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HealthResources healthResources)
    {
        return toAjax(healthResourcesService.updateHealthResources(healthResources));
    }

    /**
     * 删除健康资讯资源
     */
    @PreAuthorize("@ss.hasPermi('manage:resources:remove')")
    @Log(title = "健康资讯资源", businessType = BusinessType.DELETE)
	@DeleteMapping("/{resourceIds}")
    public AjaxResult remove(@PathVariable Long[] resourceIds)
    {
        return toAjax(healthResourcesService.deleteHealthResourcesByResourceIds(resourceIds));
    }
}
